package com.sc.nft.admin.controller;

import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.admin.request.NamePageRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.vo.ActivityPropsVO;
import com.sc.nft.entity.vo.appPackageManage.AppPackManageAdminPageVO;
import com.sc.nft.service.AppPackageManageService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * (AppPackageMange)表控制层
 *
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/appPackageManage")
@Api(tags = "应用市场包管理")
public class AppPackageMangeController {
    /**
     * 服务对象
     */
    private final AppPackageManageService appPackageManageService;


    @ApiOperation(value = "应用市场包管理列表", notes = "应用市场包管理列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/adminPage", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<AppPackManageAdminPageVO> adminPage(@RequestBody NamePageRequest request)  {
        return PageResult.success(appPackageManageService.adminPage(request.getName(), request.getPageNo(), request.getPageSize()));
    }

    @ApiOperation(value = "应用市场包管理开启", notes = "应用市场包管理开启", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/enable", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result enable(@Valid @RequestBody IdRequest idRequest) {
        appPackageManageService.enable(idRequest.getId());
        return Result.success();
    }

    @ApiOperation(value = "应用市场包管理关闭", notes = "应用市场包管理关闭", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/disable", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result disable(@Valid @RequestBody IdRequest idRequest) {
        appPackageManageService.disable(idRequest.getId());
        return Result.success();
    }
   
}
